home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************************************
- *
- *
- * ObjectMacZapp -- a standard Mac OOP application template
- *
- *
- *
- * ZDialog.h -- a dialog box
- *
- *
- *
- *
- *
- * © 1996, Graham Cox
- * Additional modifications/enhancements by Joe Strout.
- *
- *
- *
- *************************************************************************************************/
-
- #pragma once
-
- #ifndef __ZDIALOG__
- #define __ZDIALOG__
-
- #ifndef __ZWINDOW__
- #include "ZWindow.h"
- #endif
-
- typedef struct
- {
- short item;
- short groupID;
- }
- RGroupEntry, *RGroupPtr, **RGroupHdl;
-
- // 'ictb' parsing stuff:
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- // first part of resource is array of these:
-
- typedef struct
- {
- unsigned short iData; // item data flags (enumerated below)
- unsigned short iOffset; // offset to data table
- }
- ictbItemEntry, *ictbPtr, **ictbHandle;
-
- // text info stored in tables like this:
-
- typedef struct
- {
- short txtFont; // font ID or offset to name
- Style txtFace; // face- plain, bold, etc
- char filler;
- short txtSize; // font size
- RGBColor txtFColour; // text colour
- RGBColor txtBColour; // background colour
- short txtMode; // transfer mode
- }
- ictbTextStyleTable, *ictbTablePtr;
-
- // iData is bitfield arranged thus:
-
- enum
- {
- fFamChange = 1, // change the font
- fFaceChange = 2, // change the face
- fSizeChange = 4, // change the size
- fFColourChange = 8, // change the colour
- fAddFontSize = 16, // add the size
- fBColourChange = 8192, // change the background colour
- fModeChange = 16384, // change the mode
- fIsFNameOffset = 32768 // txtFont is offset to font name
- };
-
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- // message sent to dialog's boss when dialog closed OK. You can listen for this
- // so that you get informed when the user closes the dialog. The boss listens for
- // this anyway- you just need to override ReceiveMessage to take action.
-
- enum
- {
- kMsgDialogSuccessfullyClosed = 'dlg$',
- kMsgDialogCancelled = 'dlg-'
- };
-
- // class definition
-
- class ZDialog : public ZWindow
- {
- protected:
- Boolean isModal; // TRUE if dialog is modal
- RGroupHdl rGroupList; // array of rGroupEntrys for managing radio groups
- ictbHandle ictb; // local handle to ictb resource, if any
- short signalDismiss; // set to ok or cancel to close dialog safely in response to messages
-
- public:
-
- ZDialog(ZCommander* aBoss, const short dialogID);
- virtual ~ZDialog();
-
- virtual void InitZWindow();
- virtual void Draw();
- virtual Boolean Close(const short phase);
- virtual void AdjustCursor(const Point mouse, const short modifiers);
- virtual void Click( const Point mouse, const short modifiers );
- virtual void Activate();
- virtual void Deactivate();
- virtual void Idle();
- virtual void Type( const char theKey );
-
- // command stuff
-
- virtual void UpdateMenus();
-
- // std edit commands
-
- virtual Boolean CanPasteType();
- virtual void DoCut();
- virtual void DoCopy();
- virtual void DoPaste();
- virtual void DoClear();
-
- // dialog specific stuff
-
- virtual void SetUp();
- virtual void ClickItem( const short theItem );
- virtual Boolean CloseDialog();
- virtual Boolean Filter( EventRecord* theEvent );
- virtual void DrawUserItem( const short item );
-
- // convenience functions
-
- virtual void SetValue( const short item, const long value );
- virtual void SetValue( const short item, const int value ) { SetValue(item, (long) value); }
- virtual void SetValue( const short item, const short value ) { SetValue(item, (long) value); }
- virtual void SetValue( const short item, const Str255 value );
- virtual void SetValue( const short item, const double value );
- virtual void SetValue( const short item, const float value ) { SetValue(item, (double) value); }
-
- virtual long GetValue( const short item );
- virtual void GetValueAsText( const short item, Str255 aStr );
- virtual float GetValueAsFloat( const short item );
- virtual void HiliteItem( const short item, const short state );
- virtual void OutlineDefaultItem();
- virtual void GetItemBounds( const short item, Rect* bounds );
- virtual short FindItem( const Point localMouse );
-
- inline Boolean IsModal() { return isModal; };
-
- protected:
-
- virtual void MakeMacWindow( const short dialogID );
- virtual Boolean HasEditFields();
- virtual void SetUpUserItems();
- virtual void SetUpRadioGroups();
- virtual void ParseRButtonTitle( Str255 buttonTitle, short* groupID, Boolean* isDefault );
- virtual void HandleRButtonGroupClick( const short item );
- virtual void FakeClick( const short item );
- virtual short GetItemType( const short item );
-
- // ictb stuff:
-
- virtual void SetTEItemDataFromIctb( const short teItem, Boolean applyChanges = TRUE );
- virtual void AddGreyscaleEffects();
- };
-
- /*
-
- This is a ZWindow that manages a modal or modeless dialog using the dialog manager. For specific
- dialogs, you need to override the SetUp, ClickItem and CloseDialog methods to handle your par-
- ticular items. The rest is done for you. Moveable modals just work- no special effort.
-
- This class now handles radio button groups in a very easy to set up way. In your dialog
- template (DITL), append a double-slash plus a number to the name of a button to set the group
- the button is a part of- e.g. "My Button//1". The appended info is used to set up a table of
- radio groups that is private to ZDialog. Naturally buttons with the same number interact as
- a group. The extra information in the button title is removed
- and is not visible when the dialog is shown. Clicks in such buttons are handled internally by
- the default ClickItem() method. If you want to handle radio groups yourself in the old way (i.e.
- without any help from ZDialog, simply leave off the group info in the button title. Thus this
- is entirely backward-compatible, too! Now was that so hard that Apple couldn't have put this
- into the Dialog Manager?
-
- */
-
- // method to convert real numbers to strings (without using ANSI library)
- void RealToString( const double num, Str255& str );
-
- // compiler flags:
-
- // this class can now provide some support for the Apple Grayscale Appearance. If you do not want this
- // additional support ( which draws 3D borders around edit fields and list boxes and draws user items as
- // a 3D embossed line ), comment out the following compiler flag
-
- #define _GREYSCALE_APPEARANCE 1
-
- // static function for drawing 3D effect rectangles:
-
- void FrameGrayRect( Rect* aRect );
-
-
- #endif